<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'newPwd.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
	<script>
			function updatepwd(){
				var email=$("#email").val();
				if($("#newpwd").val()==""||$("#newpwd").val()==null){
					alert("新密码不能为空");
				}else{
					if($("#newpwd").val()!=$("#pwdagain").val()){
						alert("2次密码不一致");
						$("#pwdagain").val("");
					}else{
						$.post("UpdataPwdByEmailAction",{"email":email,"password":$("#newpwd").val()},function(data){
							if(data=="success"){
								alert("修改成功");
								window.location.href=$("#path").val()+"/login.jsp"; 
							}else{
								alert("修改失败");
								$("#newpwd").val("");
								$("#pwdagain").val("");
							}
						});
				    }
				}
			}
	</script>
  </head>
  
  <body>
    		新密码：<input type="password" id="newpwd"><br/>
    		再输一次：<input type="password" id="pwdagain"><br/>
    		<input type="button" value="修改" onclick="updatepwd()">
    		<input type="hidden" value="<%=request.getParameter("email")%>" id="email">
    		<input type="hidden" value="<%=request.getContextPath()%>" id="path">
  </body>
</html>
